<?php


namespace app\views;


use app\api\model\shortChainModel;
use iflow\Response;
use iflow\router\Controller;
use iflow\router\lib\request\GetMapping;

#[Controller('/')]
class indexController
{
    #[GetMapping('/')]
    public function index(): Response
    {
        return view('index', [
            'api_list' => []
        ]);
    }

    #[GetMapping('<\S+:url>')]
    public function jumpUrl(string $url): Response|bool
    {
        $url = (new shortChainModel()) -> getShortUrl($url);
        if ($url) {
            return response() -> setRedirect($url) -> data($url);
        }
        return response() -> notFount();
    }

}